package com.atguigu.gmall.task.config;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    //  每隔10秒钟发送一个消息。
    @Scheduled(cron = "0/10 * * * * ?")
    public void task01(){
        rabbitService.sendMsg(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_1,"OK");
    }

    //  下午18点钟发送一个消息。
    @Scheduled(cron = "* * 18 * * ?")
    public void task02(){
        rabbitService.sendMsg(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_18,"OK");
    }

}
